//package com.tansun.easycare.rule.ruleproj.web;
//
//import com.tansun.easycare.core.persistence.Page;
//import com.tansun.easycare.rule.common.JsonMessage;
//import com.tansun.easycare.rule.common.ResultVo;
//import com.tansun.easycare.rule.ruleproj.entity.RuleReferenceEntity;
//import com.tansun.easycare.rule.ruleproj.entity.RuleProject;
//import com.tansun.easycare.rule.ruleproj.service.RuleProjectReferenceService;
//import com.tansun.easycare.rule.ruleproj.service.RuleProjectService;
//import com.tansun.rule.utils.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.Serializable;
//import java.util.List;
//
///**
// * 项目引用的controller
// * 20190926 ljt
// */
//@Controller
//@RequestMapping("${adminPath}/ruleproj/ruleReference")
//public class RuleProjectReferenceController {
//    @Autowired
//    private RuleProjectReferenceService ruleReferenceService;
//    @Autowired
//    private RuleProjectService ruleProjectService;
//    /**
//     * 引用项目的相关操作 20190916 ljt
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("index")
//    public ResultVo ruleReference(@RequestParam(value = "projectCode")String projectCode){
//        ResultVo resultVo = new ResultVo();
//       // JsonMessage jsonMessage = new JsonMessage();
//        List<String> refProNameList = ruleReferenceService.getRefProCode(projectCode);
//        List<RuleProject> allProject = ruleProjectService.findExcludeCode(projectCode);
//        resultVo.setResult(true);
//        resultVo.setData((Serializable)refProNameList);
//        resultVo.setAllProject((Serializable)allProject);
//        return resultVo;
//    }
//
//    /**
//     * 项目引用中点击引用跳转的弹框页面 20190930 ljt
//     * @param projectCode
//     * @param request
//     * @param response
//     * @return
//     */
//    @RequestMapping("indexPage")
//    public ModelAndView ruleReferencePage(@RequestParam(value = "projectCode")String projectCode, HttpServletRequest request, HttpServletResponse response,@RequestParam(value = "isOne")String isOne){
//        ModelAndView modelAndView = new ModelAndView("rule/ruleproj/ruleProjectReference");
//        String refProjectCodeList = request.getParameter("refProjectCodeList");
//        Page<RuleProject> page = ruleProjectService.findPageRefExcludeCode(new Page<RuleProject>(request, response), new RuleProject(), projectCode);
//        RuleProject ruleProject = ruleProjectService.getByCodeForRef(projectCode);
//        List<String> refCodeList = ruleReferenceService.getRefProCode(projectCode);
//        modelAndView.addObject("ruleProject",ruleProject);
//        modelAndView.addObject("page",page);
//        if("one".equals(isOne)){//判断是否是点击引用时候发起请求还是分页时候
//            modelAndView.addObject("refList",String.join(",",refCodeList));
//        }else{
//            modelAndView.addObject("refList",refProjectCodeList);
//        }
//        return modelAndView;
//    }
//
//    /**
//     * 规则引用的保存操作
//     * @return
//     */
//    @RequestMapping("save")
//    @ResponseBody
//    public JsonMessage save(@RequestBody RuleReferenceEntity ruleReferenceEntity){
//         JsonMessage jsonMessage = new JsonMessage(false);
//        try {
//            ruleReferenceService.insertList(ruleReferenceEntity);
//            jsonMessage.setResult(true);
//            jsonMessage.setMessage("保存规则引用成功");
//        } catch (Exception e) {
//            jsonMessage.setMessage(e.getMessage());
//        }
//        return  jsonMessage;
//    }
//}
